package Chpter4; 

public class Example27 {
	public static void main(String[] args) {
		//try..catch for catch exception
		try {
			int result=divide(4,-2);
			System.out.println(result);
		}catch(DivideByMinusException e){
			System.out.println(e.getMessage());
		}
	}
	public static int divide(int x,int y) throws DivideByMinusException{
		if(y<0) {
			//use key word throw for announcing exception
			throw new DivideByMinusException("被除数是负数");
		}
		int result=x/y;
		return result;
	}

}
